package com.crois.barrier.server.config;

import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author Hou Ze Yu
 * @description
 * @date 2020/10/12
 */
@Component("runningConfig")
public class RunningConfig implements ApplicationListener<WebServerInitializedEvent> {

    private static int serverPort;

    private static String contextPath;

    private static volatile boolean isServerInitialized = false;

    @Override
    public void onApplicationEvent(WebServerInitializedEvent webServerInitializedEvent) {
        serverPort = webServerInitializedEvent.getWebServer().getPort();
        isServerInitialized = true;
    }
    public static int getServerPort() {
        return serverPort;
    }
}
